#include <iostream>
#include "bignumber.h"
#include "shellsort.hpp"
#include "mergesort.hpp"
#include "selectionsort.hpp"
#include "quicksort.hpp"

#define N 1000000
int main()
{

    double startTime = clock();

    srandom(clock());
   
    char A[] = {'1','2','3','4','5','6','7','8','9'};
    int n = N;
    BigNumber nums[N];
    char *data = NULL;
    // 随机生成N个大数
    for (int i = 0; i < N; i++) {
        int len = random() % 1000 + 1000;
        if (len > 2000) {
            printf("len > 2000");
        }
        data = (char *)malloc((len) * sizeof(char));
        char *temp = data;
        for (int j = 0; j < len; j++) {
            int num = random() % 9;
            *temp = A[num];
            temp++;
        }
        BigNumber big = BigNumber(data);
        nums[i] = big;
    }
    printf("生成%d个大数耗时:  %f secs\n",  N,(clock() - startTime) / CLOCKS_PER_SEC);

    // 选择排序，归并排序，快速排序，希尔排序，基数排序
    startTime = clock();
//    selectionSort(nums, N);
     mergeSort(nums, 0, N - 1);
    // quickSort(nums, 0, N -1);
    // shell_sort(nums, N);
    double endTime = clock();
    printf("归并排序:数据量 = %d  耗时:  %f secs\n",  N,(endTime - startTime) / CLOCKS_PER_SEC);

}
